package xiaozhi.modules.sys;

import java.util.UUID;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

import xiaozhi.modules.sys.dto.SysUserDTO;
import xiaozhi.modules.sys.service.SysUserService;

@SpringBootApplication
public class InitAdminUser {

    public static void main(String[] args) {
        ApplicationContext context = SpringApplication.run(InitAdminUser.class, args);
        
        SysUserService sysUserService = context.getBean(SysUserService.class);
        
        // 创建管理员用户
        SysUserDTO userDTO = new SysUserDTO();
        userDTO.setUsername("admin");
        userDTO.setPassword("Admin@123"); // 设置一个强密码
        
        try {
            sysUserService.save(userDTO);
            System.out.println("管理员用户创建成功: username=admin");
        } catch (Exception e) {
            System.err.println("创建管理员用户失败: " + e.getMessage());
            e.printStackTrace();
        }
        
        // 退出应用
        System.exit(0);
    }
}